package com.blb.ioc.demo2;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @ComponentScan扫描组件
 * @Configuration配置类
 */
@ComponentScan(basePackages = "com.blb.ioc.demo2")
@Configuration
public class ComputerConfig {

    public static void main(String[] args) {
        //创建注解配置的IOC容器
        ApplicationContext context = new AnnotationConfigApplicationContext(ComputerConfig.class);
        Computer computer = context.getBean(Computer.class);
        computer.start();
    }
}
